package com.jdrx.sw.sewage.api.web;

import com.jdrx.platform.commons.rest.beans.vo.ResponseVO;
import com.jdrx.platform.commons.rest.factory.ResponseFactory2;
import com.jdrx.sw.sewage.beans.dto.ForecastInfoQueryDTO;
import com.jdrx.sw.sewage.beans.dto.ForecastQueryDTO;
import com.jdrx.sw.sewage.beans.dto.PromptlyHandleDTO;
import com.jdrx.sw.sewage.beans.vo.ForecastInfoVO;
import com.jdrx.sw.sewage.beans.vo.ForecastVO;
import com.jdrx.sw.sewage.beans.vo.base.PageVO;
import com.jdrx.sw.sewage.common.constant.Constant;
import com.jdrx.sw.sewage.service.ForecastServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/api/forecast")
@Api(value = "AI预警模块")
public class ForecastController {

    public static final Logger logger = LoggerFactory.getLogger(AlarmApi.class);

    @Autowired
    private ForecastServiceImpl forecastServiceImpl;

    @ApiOperation(value = "AI预警悬浮球分页列表")
    @RequestMapping(value = "selectForecastByPage", method = RequestMethod.POST)
    public ResponseVO<PageVO<ForecastVO>> selectForecastByPage(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                               @RequestHeader(Constant.TENANT_ID) String tenantId,
                                                               @RequestBody ForecastQueryDTO forecastQueryDTO) {
        return ResponseFactory2.ok(forecastServiceImpl.selectForecastByPage(forecastQueryDTO));
    }

    @ApiOperation(value = "AI预警悬浮球详情")
    @RequestMapping(value = "selectForecastInfo", method = RequestMethod.POST)
    public ResponseVO<ForecastInfoVO> selectForecastInfo(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                         @RequestHeader(Constant.TENANT_ID) String tenantId,
                                                         @RequestBody ForecastInfoQueryDTO forecastInfoQueryDTO) {
        return ResponseFactory2.ok(forecastServiceImpl.selectForecastInfo(forecastInfoQueryDTO));
    }

    @ApiOperation(value = "AI预警悬浮球立即处理")
    @RequestMapping(value = "promptlyHandle", method = RequestMethod.POST)
    public ResponseVO promptlyHandle(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                     @RequestHeader(Constant.TENANT_ID) String tenantId,
                                     @RequestBody PromptlyHandleDTO promptlyHandleDTO) {
        forecastServiceImpl.promptlyHandle(promptlyHandleDTO);
        return ResponseFactory2.ok();
    }
}
